home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 303_01.zip / DOC < prev    next >
Text File  |  1993-04-01  |  9KB  |  265 lines

  1.  
  2.  
  3.  
  4.                               A Disassembler
  5.  
  6.  
  7.  
  8.                              1.  Introduction
  9.  
  10.        This document describes the first release of a  disassembler
  11.        for UNIX executable files.  The key features are:
  12.  
  13.          1.  For object  files  the  output  can  be  assembled  to
  14.              generate  the  same  object  module, (apart from minor
  15.              variations in symbol table ordering) as the input.
  16.  
  17.          2.  For  stripped  executable  files  object  modules  and
  18.              libraries  may  be  scanned, modules in the main input
  19.              identified and  the  appropriate  names  automatically
  20.              inserted into the output.
  21.  
  22.          3.  An option is  available  to  convert  most  non-global
  23.              names  into local symbols, which cuts down the symbols
  24.              in the generated assembler file.
  25.  
  26.          4.  The disassembler copes reasonably with modules  merged
  27.              with the -r option to ld, generating a warning message
  28.              as to the number of modules involved.
  29.  
  30.        At present this is  available  for  certain  Motorola  68000
  31.        ports of UNIX System III and System V. Dependencies on
  32.  
  33.          a.  Instruction set.
  34.  
  35.          b.  Object module format.
  36.  
  37.          c.  Library module format.
  38.  
  39.          d.  Assembler output format.
  40.  
  41.        are hopefully sufficiently localised  to  make  the  product
  42.        useful as a basis for other disassemblers for other versions
  43.        of UNIX.
  44.  
  45.        The product is thus distributed in source form at present.
  46.  
  47.  
  48.                                  2.  Use
  49.  
  50.        The disassembler is run by entering:
  51.  
  52.             unc mainfile lib1 lib2 ...
  53.  
  54.        The first named file is the file to be  disassembled,  which
  55.        should  be  a  single  file,  either  an  object  module,  a
  56.        (possibly stripped) executable file, or  a  library  member.
  57.        Library members are designated using a parenthesis notation,
  58.        thus:
  59.  
  60.  
  61.  
  62.        Issue 1I1                - Page 1 -                      1G1
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                               A Disassembler
  71.  
  72.  
  73.  
  74.             unc '/lib/libc.a(printf.o)'
  75.  
  76.        It is usually necessary to escape the arguments in this case
  77.        to  prevent  misinterpretation  by  the  shell. Libraries in
  78.        standard places such as /lib and /usr/lib may  be  specified
  79.        in the same way as to ld, thus
  80.  
  81.             unc '-lc(printf.o)'
  82.             unc '-lcurses(wmove.o)'
  83.  
  84.        As an additional facility, the list of directories  searched
  85.        for  libraries  may  be  varied  by  setting the environment
  86.        variable LDPATH, which is interpreted similarly to the shell
  87.        PATH variable, and of course defaults to
  88.  
  89.             LDPATH=/lib:/usr/lib
  90.  
  91.        As a further facility, the insertion of lib  before  and  .a
  92.        after  the  argument may be suppressed by using a capital -L
  93.        argument, thus to print out the assembler  for  /lib/crt0.o,
  94.        then the command
  95.  
  96.             unc -Lcrt0.o
  97.  
  98.        should have the desired effect.
  99.  
  100.        Second and subsequent file arguments are only referenced for
  101.        stripped  executable files, and may consist of single object
  102.        files and library members, using the same syntax as  before,
  103.        or whole libraries of object files, thus:
  104.  
  105.             unc strippedfile -Lcrt0.o -lcurses -ltermcap '-lm(sqrt.o)' -lc
  106.  
  107.        It is advisable to make some effort to put the libraries  to
  108.        be  searched  in  the  order  in  which they were originally
  109.        loaded. This is because the search for  each  module  starts
  110.        where the previously matched module ended.  However, no harm
  111.        is done if this rule is not adhered to apart from  increased
  112.        execution   time   except   in  the  rare  cases  where  the
  113.        disassembler is confused by object modules  which  are  very
  114.        nearly similar.
  115.  
  116.  
  117.                           3.  Additions
  118.  
  119.        The following options are available to modify the  behaviour
  120.        of the disassembler.
  121.  
  122.          -o file      Causes output to be  sent  to  the  specified
  123.                       file instead of the standard output.
  124.  
  125.  
  126.  
  127.  
  128.        Issue 2I2                - Page 2 -                      2G2
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                               A Disassembler
  137.  
  138.  
  139.  
  140.          -t prefix    Causes temporary files to be created with the
  141.                       given  prefix.  The  default prefix is split,
  142.                       thus  causing  two  temporary  files  to   be
  143.                       created  with  this  prefix  in  the  current
  144.                       directory. If it is desired, for example,  to
  145.                       create   the  files  as  /tmp/xx*,  then  the
  146.                       argument -t /tmp/xx  should  be  given.  Note
  147.                       that the temporary files may be very large as
  148.                       a complete map of the text and data  segments
  149.                       is generated.
  150.  
  151.          -a           Suppresses  the  generation   of   non-global
  152.                       absolute  symbols from the output. This saves
  153.                       output  from  C  compilations   without   any
  154.                       obvious  problems,  but  the  symbols  are by
  155.                       default included in the name of producing  as
  156.                       nearly  identical  output  as possible to the
  157.                       original source.
  158.  
  159.          -s           Causes an additional scan to take place where
  160.                       all  possible  labels  are  replaced by local
  161.                       symbols. The local symbols  are  inserted  in
  162.                       strictly ascending order, starting at 1.
  163.  
  164.          -v           Causes a blow-by-blow account  of  activities
  165.                       to be output on the standard error.
  166.  
  167.          -V           Causes shlib symbol values to be  printed  at
  168.                       the  top  of the output, if they exist in the
  169.                       symbol  table.  normally  these  are  ommited
  170.                       because they are constant values derived form
  171.                       the file /lib/shlib.ifile
  172.  
  173.  
  174.                            4.  Diagnostics etc
  175.  
  176.        Truncated or garbled object and library files usually  cause
  177.        processing to stop with an explanatory message.
  178.  
  179.        The only other kinds of message are  some  passing  warnings
  180.        concerning  obscure  constructs  not  handled,  such  as the
  181.        relocation of byte fields, or the relocation of  overlapping
  182.        fields. Occasionally a message
  183.  
  184.             Library clash: message
  185.  
  186.        may appear and processing cease. This message is found where
  187.        at  a  late  stage  in  processing  libraries,  the  program
  188.        discovers that due to the extreme similarity of two or  more
  189.        library  members,  it has come to the wrong conclusion about
  190.        which one to use. The remedy here is to  spell  out  to  the
  191.  
  192.  
  193.  
  194.        Issue 3I3                - Page 3 -                      3G3
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                               A Disassembler
  203.  
  204.  
  205.  
  206.        program which members to take in which order.
  207.  
  208.  
  209.                           5.  Future development
  210.  
  211.        In the future it is hoped  to  devise  ways  of  making  the
  212.        disassembler  independent of all the above-mentioned version
  213.        dependencies,  by  first  reading  a  files  defining  these
  214.        things.  This  will  probably  be  applied  after the Common
  215.        Object Format becomes more standard.
  216.  
  217.        In the long term it would be desirable and useful to enhance
  218.        the   product   to  produce  compilable  C  in  addition  to
  219.        assemblable assembler. Stages in the  process  are  seen  as
  220.        follows:
  221.  
  222.          1.  Better identification of basic  blocks  in  the  code.
  223.              Switch  statements  are  a  major problem here, as are
  224.              constant data held in the text segment.
  225.  
  226.          2.  Marrying of data to the corresponding text. It  is  in
  227.              various  places  hard to divorce static references "on
  228.              the fly" (e.g.  strings,  and  switch  lists  in  some
  229.              implementations)  from static at the head of a module.
  230.              This is part  of  the  problem  of  identifying  basic
  231.              blocks.
  232.  
  233.          3.  Compilation of header  files  to  work  out  structure
  234.              references   within  the  text.  At  this  stage  some
  235.              interaction may be needed.
  236.  
  237.        Meanwhile the product is one which is a useful tool  to  the
  238.        author  in  its present form. Comments and suggestions as to
  239.        the most practical method of improving the  product  in  the
  240.        ways   suggested  or  in  other  ways  would  be  gratefully
  241.        considered.
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.        Issue 4I4                - Page 4 -                      4G4
  261.  
  262.  
  263.  
  264.  
  265.